package com.gitee.wsl.common.chart.render.background.axis

import android.graphics.Color
import android.graphics.Paint
import com.gitee.wsl.common.chart.ChartEnum
import com.gitee.wsl.common.chart.render.background.axis.step.ListStepCalculator
import com.gitee.wsl.common.chart.render.background.axis.step.StepCalculator
import com.gitee.wsl.common.chart.render.background.axis.step.StringStepCalculatorWarp

/**
 * @ClassName BaseAxis
 * @Description  轴(axis)基类，定义了刻度，标签，等的属性
 * @author XiongChuanLiang<br/>(xcl_168@aliyun.com)
 */
open class BaseAxis {
    //轴线画笔
     val axisPaint: Paint by lazy {
        Paint().apply {
            color = Color.BLACK
            isAntiAlias = true
            strokeWidth = 5f
        }
    }

    //数据轴刻度线与边上的标注画笔
     val tickMarkPaint: Paint  by lazy {
        Paint().apply {
            color = Color.BLACK
            isAntiAlias = true
            strokeWidth = 3f
        }
    }

     val tickLabelPaint: Paint  by lazy {
         Paint().apply {
             color = Color.BLACK
             isAntiAlias = true
             textAlign = Paint.Align.RIGHT
             textSize = 18f
         }
     }

    //是否显示轴(包含轴线，刻度线和标签)
    var isAxisVisible = true

    //是否显示轴线
    var isAxisLineVisible = true

    //数据轴刻度线与边上的标注是否显示
    var isTickMarksVisible = true
    var isAxisLabelsVisible = true

    //刻度标记文字旋转角度
    var tickLabelRotateAngle = 0.0f //-45f;

    var axisLocation = ChartEnum.AxisLocation.LEFT

    var stepDataSource: StepCalculator<String> = ListStepCalculator.default()

    fun <T> setStepCalculator(step:StepCalculator<T>){
        stepDataSource = StringStepCalculatorWarp(step)
    }

    fun hideTickMarks() {
        isTickMarksVisible=false
    }

    fun hideAxisLine() {
        isAxisLineVisible = false
    }

    fun hide() {
       isAxisVisible = false
    }

    fun show() {
        isAxisVisible=true
    }


}
